<template>
	<!-- 最大盒子 -->
	<s-layout :tabbarshow="false" id="layout" navbar="normal" :title="''" :autoBack="true" leftIconColor="$uni-text-color" :bgColor="'rgba(0,0,0,0)'">
		<view class="max_box" :style="{ backgroundImage: `url(${baseUrl}/uploads/uniapp_image/staff_v1/laowupaiqian_bg3@2.png)`, paddingTop: safeAreaInsets?.top + 'px', height: `calc(100vh - ${safeAreaInsets?.top}px)` }">
			<view class="title">{{ department_title }}</view>
			<view class="wrap">
				<view class="yellow_bg"></view>
				<!-- <view class="wrap_line" :style="{ backgroundImage: `url(${baseUrl}/uploads/uniapp_image/staff_v1/laowupaiqian_TITLE.png)`}">
					<view class="title" >填写信息</view>
				</view> -->
				<view class="labor_dispatching">
					<!-- <view class="advertising_position">
						<image :src="`${baseUrl}/uploads/uniapp_image/staff_v1/laowupaiqian_icon1@2.png`" mode="aspectFill" />
					</view> -->
					
					<view class="form_title_box">
						<view class="form_pages">{{ pagination }}/4</view>
						<view class="form_title" v-if="!sign_form_show">{{ entry_registration_title }}</view>
					</view>
					<!-- 表单盒子 -->
					<view class="form_box">
						<scroll-view scroll-y :style="{ height: sign_form_show ? '55vh' : '48vh' }" :enable-back-to-top="true">
							<!-- 员工入职登记表 表单结构 -->
							<u--form :labelStyle="labelStyle" labelPosition="left" :model="RegistrationForm" :rules="Registration_rules" ref="RegistrationRef" :borderBottom="false" v-if="!sign_form_show">
								<!-- 基本信息 -->
								<template v-if="pagination == 1">
									<!-- 详细地址 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="现地址" prop="address" ref="address">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入现地址" v-model="RegistrationForm.address" border="none"></u--input>
									</u-form-item>
									<!-- 政治面貌 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="政治面貌" prop="political_status" ref="political_status" @tap="political_status_open">
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择政治面貌" v-model="political_status_title" border="none"></u--input>
									</u-form-item>
									<!-- 入职日期 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="入职日期" prop="join_date" ref="join_date" @tap="join_date_open">
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择入职日期" v-model="RegistrationForm.join_date" border="none"></u--input>
									</u-form-item>
									<!-- 户籍类型 -->
									<u-form-item :required="true"  class="" :borderBottom="false" :labelWidth="120" label="户籍类型" prop="hukou_type" ref="hukou_type">
										<u-radio-group v-model="RegistrationForm.hukou_type">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in hukou_type_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>

									<!-- 籍贯 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="籍贯" prop="nativ_place" ref="nativ_place">
										<u--input :placeholderStyle="'fontSize:10px'" :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入籍贯" v-model="RegistrationForm.nativ_place" border="none"></u--input>
									</u-form-item>
									
									<!-- 婚姻状况  -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="婚姻状况" prop="marital_status" ref="marital_status" @tap="marital_status_open">
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择婚姻状况" v-model="marital_status_title" border="none"></u--input>
									</u-form-item>
									
									<!-- 毕业院校 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="毕业院校" prop="graduate_school" ref="graduate_school">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入毕业院校" v-model="RegistrationForm.graduate_school" border="none"></u--input>
									</u-form-item>
									<!-- 最高学历 -->
									<u-form-item v-if="RegistrationForm.graduate_school" :borderBottom="false" :labelWidth="100" label="最高学历" prop="education" ref="education" @tap="education_open">
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择最高学历" v-model="RegistrationForm.education" border="none"></u--input>
									</u-form-item>
									<!-- 专业 -->
									<u-form-item v-if="RegistrationForm.graduate_school" :borderBottom="false" :labelWidth="100" label="专业" prop="major" ref="major">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入专业" v-model="RegistrationForm.major" border="none"></u--input>
									</u-form-item>
									<!-- 毕业日期 -->
									<u-form-item v-if="RegistrationForm.graduate_school" :borderBottom="false" :labelWidth="100" label="毕业日期" prop="graduation_date" ref="graduation_date" @tap="graduation_date_open">
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择毕业日期" v-model="RegistrationForm.graduation_date" border="none"></u--input>
									</u-form-item>

									<!-- 户口所在地 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="户口所在地" prop="householdaddress" ref="householdaddress">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入户口所在地" v-model="RegistrationForm.householdaddress" border="none"></u--input>
									</u-form-item>
								</template>
								<!-- 紧急联系人 -->
								<template v-if="pagination == 2">
									<!-- 紧急联系人 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="150" label="紧急联系人" prop="emergency_contact" ref="emergency_contact">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入紧急联系人" v-model="RegistrationForm.emergency_contact" border="none"></u--input>
									</u-form-item>
									<!-- 紧急联系人电话 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="150" label="联系人电话" prop="emergency_contact_mobile" ref="emergency_contact_mobile">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="number" placeholder="请输入紧急联系人电话" v-model="RegistrationForm.emergency_contact_mobile" border="none"></u--input>
									</u-form-item>
									<!-- 紧急联系人关系 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="170" label="紧急联系人关系" prop="emergency_contact_relation" ref="emergency_contact_relation">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入紧急联系人关系" v-model="RegistrationForm.emergency_contact_relation" border="none"></u--input>
									</u-form-item>
									<!-- 紧急联系人地址 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="170" label="紧急联系人地址" prop="emergency_contact_address" ref="emergency_contact_address">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入紧急联系人地址" v-model="RegistrationForm.emergency_contact_address" border="none"></u--input>
									</u-form-item>
								</template>
								<!-- 健康状况 -->
								<template v-if="pagination == 3">
									<!-- 视力 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="160" label="视力" prop="eyesight" ref="eyesight">
										<u-radio-group v-model="RegistrationForm.eyesight">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in eyesight_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 听力 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="160" label="听力" prop="hearing" ref="hearing">
										<u-radio-group v-model="RegistrationForm.hearing">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in hearing_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 是否曾有工伤 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="360" label="是否曾有工伤" prop="is_occupational_injury" ref="is_occupational_injury">
										<u-radio-group v-model="RegistrationForm.is_occupational_injury">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_occupational_injury_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 是否伤残 -->
									<u-form-item :required="true"  class="" :borderBottom="false" :labelWidth="360" label="是否伤残" prop="is_disability" ref="is_disability">
										<u-radio-group v-model="RegistrationForm.is_disability">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_disability_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 伤残等级 -->
									<template v-if="RegistrationForm.is_disability">
										<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="伤残等级"  prop="disability_level" ref="disability_level" @tap="disability_level_open">
											<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择伤残等级" v-model="disability_level_title" border="none"></u--input>
										</u-form-item>
									</template>
									<!-- 是否曾高危工作 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="360" label="是否曾高危工作 " prop="is_high_risk" ref="is_high_risk  ">
										<u-radio-group v-model="RegistrationForm.is_high_risk">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_high_risk_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>  
									<!-- 是否有传染病 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="360" label="是否有传染病" prop="is_contagion" ref="is_contagion">
										<u-radio-group v-model="RegistrationForm.is_contagion">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_contagion_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item> 
									<!-- 传染病详情 -->
									<template v-if="RegistrationForm.is_contagion">
										<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="传染病详情"  prop="contagion_detail" ref="contagion_detail">
											<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入传染病详情" v-model="RegistrationForm.contagion_detail" border="none"></u--input>
										</u-form-item>
									</template>
									<!-- 身高 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="身高" prop="height" ref="height">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入身高" v-model="RegistrationForm.height" border="none"></u--input>
									</u-form-item>
									<!-- 体重 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="体重" prop="weight" ref="weight">
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入体重" v-model="RegistrationForm.weight" border="none"></u--input>
									</u-form-item>
									<!-- 近半年体检 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="100" label="近半年体检" prop="recent_inspection" ref="recent_inspection">
										<!-- <u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入近半年体检" v-model="RegistrationForm.recent_inspection" border="none"></u--input> -->
									</u-form-item>
									<up-textarea :placeholderStyle="{color:'#8080a1',fontSize:'26rpx'}" height="80" v-model="RegistrationForm.recent_inspection" placeholder="请输入近半年体检内容,没有则填无" border="none"></up-textarea>
								</template>
								<!-- 前用人单位信息 -->
								<template v-if="pagination == 4">
									<!-- 是否签有保密协议 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="360" label="是否签有保密协议" prop="is_confidentiality_agreement" ref="is_confidentiality_agreement">
										<u-radio-group v-model="RegistrationForm.is_confidentiality_agreement">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_confidentiality_agreement_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 是否有纠纷 -->
									<u-form-item :required="true" :borderBottom="false" :labelWidth="360" label="是否有纠纷" prop="is_legal_dispute" ref="is_legal_dispute">
										<u-radio-group v-model="RegistrationForm.is_legal_dispute">
											<u-radio shape="square" :customStyle="{marginRight: '16px'}" v-for="(item, index) in is_legal_dispute_columns" :key="index" :label="item.name" :name="item.value"></u-radio>
										</u-radio-group>
									</u-form-item>
									<!-- 上家离职时间 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="上家离职时间" prop="resignation_time" ref="resignation_time" @tap="lz_re_time_open" >
										<u--input disabled :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请选择离职时间" v-model="RegistrationForm.resignation_time" border="none"></u--input>
									</u-form-item>
									<!-- 离职原因 -->
									<u-form-item :borderBottom="false" :labelWidth="100" label="离职原因" prop="reason_to_leave" ref="reason_to_leave" >
										<u--input :clearable="false" disabledColor="rgba(0,0,0,0)" inputAlign="right" type="text" placeholder="请输入离职原因" v-model="RegistrationForm.reason_to_leave" border="none"></u--input>
									</u-form-item>
								</template>
							</u--form> 

						</scroll-view>
					</view>
					<view class="button_box" v-if="!sign_form_show">
						<view class="left_button" @tap="lastStep">上一步</view>
						<view class="right_button" @tap="nextStep">{{ pagination == 4 ? '签署入职登记' : '下一步' }}</view>
					</view>
					<button class="nextbutton" @tap="submitForm" v-if="sign_form_show">去签署</button>
				</view>
			</view>
		</view>
	</s-layout>
	<!---选择类型-->
	<up-action-sheet :show="showSex" :actions="showSexActions" title="请选择性别" @close="showSex = false" :closeable="false" @select="sexSelect" :round="18" :closeOnClickAction="true"></up-action-sheet>
	<!---选择户籍-->
	<up-action-sheet :show="showIDType" :actions="showIDTypeActions" title="请选择户籍类型" @close="showIDType = false" :closeable="false" @select="IDTypeSelect" :round="18" :closeOnClickAction="true"></up-action-sheet>

	<!-- 入职登记表 表单弹出框 -->
		<!-- 婚姻状况 -->
		<up-picker :closeOnClickOverlay="true" :show="marital_status_show" :columns="marital_status_columns" :title="'请选择婚姻状况'" @confirm="marital_status_confirm" @cancel="marital_status_cancel" @close="marital_status_close"></up-picker>
		<!-- 政治面貌 -->
		<up-picker :closeOnClickOverlay="true" :show="political_status_show" :columns="political_status_columns" :title="'请选择政治面貌'" @confirm="political_status_confirm" @cancel="political_status_cancel" @close="political_status_close"></up-picker>
		<!-- 最高学历 -->
		<up-picker :closeOnClickOverlay="true" :show="education_show" :columns="education_columns" :title="'请选择最高学历'" @confirm="education_confirm" @cancel="education_cancel" @close="education_close"></up-picker>
		<!-- 毕业日期 -->
		<up-datetime-picker v-model="graduation_date_time" :closeOnClickOverlay="true" :show="graduation_date_show" mode="date" :title="'请选择毕业日期'" @confirm="graduation_date_confirm" @cancel="graduation_date_cancel" @close="graduation_date_close" :minDate="-2209017943000"></up-datetime-picker>
		<!-- 入职日期 -->
		<up-datetime-picker v-model="join_date_time" :closeOnClickOverlay="true" :show="join_date_show" mode="date" :title="'请选择入职日期'" @confirm="join_date_confirm" @cancel="join_date_cancel" @close="join_date_close"></up-datetime-picker>
		<!-- 伤残等级 -->
		<up-picker :closeOnClickOverlay="true" :show="disability_level_show" :columns="disability_level_columns" :title="'请选择伤残等级'" @confirm="disability_level_confirm" @cancel="disability_level_cancel" @close="disability_level_close"></up-picker>
		<!-- 离职日期 -->
		<up-datetime-picker v-model="lz_re_time" :closeOnClickOverlay="true" :show="lz_re_time_show" mode="date" :title="'请选择离职日期'" @confirm="lz_re_time_confirm" @cancel="lz_re_time_cancel" @close="lz_re_time_close" ></up-datetime-picker>	
</template>


<script setup>
	import sheep from '@/sheep';
	import { ref, reactive, computed, watch } from 'vue';
	import { onLoad, onShow,onUnload } from '@dcloudio/uni-app';
	import { baseUrl } from "@/sheep/config";
	import { formatDate } from '@/utils/fn.js';
	const { safeAreaInsets } = uni.getSystemInfoSync();
	const is_contact = ref()
	// 用户信息
	const userInfo = sheep.$store('user').userInfo;
	const labelStyle = ref({
		color:'#333',
		fontWeight:500,
		fontSize:'26rpx'
	})
	const department_id = ref()
	const share_id = ref()
	const ids = ref()
	const department_title = ref()
	onLoad((options) => {
		ids.value = options.ids
		//获取邀请信息 （扫码之后获取） 
		postDispatchView()
		share_id.value = options.share_id
		RegistrationForm.share_id = share_id.value
		//默认用户信息
		// FormData.value.nickname = userInfo.nickname
		// FormData.value.identity_id = userInfo.identity_id
		// if(userInfo.gender == 0){
		// 	FormData.value.sex = '女'
		// }else{
		// 	FormData.value.sex = '男'
		// }
		// FormData.value.gender =userInfo.gender
		// FormData.value.mobile =userInfo.mobile

		// 获取当日日期
		const date = new Date();
		const year = date.getFullYear();
		const month = date.getMonth() + 1;
		const day = date.getDate();
		join_date_time.value = `${year}-${month}-${day}`;
		RegistrationForm.join_date = join_date_time.value
	});
	// 封装获取城市id

	const showSex = ref(false)
	const showSexActions = ref([
		{ name: '男', type: 1 },
		{ name: '女', type: 2 },
	])
	// 定义方法  状态
	function sexSelect(e) {
		FormData.value.gender = e.type
		FormData.value.sex = e.name
		showSex.value = false
	}

	const showIDType = ref(false)
	const showIDTypeActions = ref([
		{ name: '农业', type: 1 },
		{ name: '非农业', type: 2 },
	])
	// 定义方法  状态
	function IDTypeSelect(e) {
		FormData.value.huokou_type = e.type
		FormData.value.id_Type = e.name
		showIDType.value = false
	}

	//获取邀请信息 （扫码之后获取） 
	const introductionView = ref()
	const postDispatchView = async()=>{
		let params ={
			ids:ids.value
		}
		const res = await sheep.$api.dispatch.postDispatchInviteInfoView(params);
		if(res.code == 1){
			introductionView.value = res.data
			RegistrationForm.department_id = introductionView.value.department_id
			RegistrationForm.year = introductionView.value.year
			RegistrationForm.city = introductionView.value.city
			RegistrationForm.company = introductionView.value.company
			// RegistrationForm.probation_start = introductionView.value.probation_start
			// RegistrationForm.probation_end = introductionView.value.probation_end
			RegistrationForm.position = introductionView.value.position
			// RegistrationForm.wage_rates = introductionView.value.wage_rates
			RegistrationForm.salary = introductionView.value.salary
			RegistrationForm.is_enrollment = introductionView.value.is_enrollment
			RegistrationForm.is_contact = introductionView.value.is_contact
			is_contact.value = introductionView.value.is_contact

			department_title.value = res.data.department.company.name+ ' / ' +res.data.department.name
			department_id.value =  res.data.department_id
		}else{
			sheep.$helper.toast(res.msg);
		}
		
	}

	// 新加逻辑
		// 控制 员工入职登记表 && 注册信息 双表单
	const sign_form_show = ref(false) 
		// 员工入职登记表的页码
	const pagination = ref(1)
		// 表单实例
	const RegistrationRef = ref(null)
	const entry_registration_title = ref('基本信息')
	const RegistrationForm = reactive({
		nativ_place:'',					// 籍贯
		address:'',						// 详细地址
		marital_status:0,				// 婚姻状况 0=未婚 1=已婚
		political_status:'0',			// 政治面貌 0=群众 1=中共党员 2=中共预备党员 3=共青团员
		graduate_school:'',				// 毕业院校
		education:'',					// 最高学历
		major:'',						// 专业
		graduation_date:'',				// 毕业日期
		join_date:'',					// 入职日期
		emergency_contact:'',			// 紧急联系人
		emergency_contact_mobile:'',	// 紧急联系人电话
		householdaddress:'',			// 户口所在地
		emergency_contact_relation:'',	// 紧急联系人关系
		emergency_contact_address:'',	// 紧急联系人地址
		height:'',						// 身高
		weight:'',						// 体重
		eyesight:'good',				// 视力
		hearing:'good',					// 听力
		is_occupational_injury:0,		// 是否曾有工伤
		is_disability:0,				// 是否伤残
		disability_level:'',			// 伤残等级
		is_high_risk:0,					// 是否曾高危工作
		is_contagion:0,					// 是否有传染病
		contagion_detail:'',			// 传染病详情
		recent_inspection:'',			// 近半年体检
		resignation_time:'',			// 上家离职时间
		reason_to_leave:'',				// 离职原因
		is_confidentiality_agreement:0,	// 是否前有保密协议
		is_legal_dispute:0,				// 是否有纠纷
		hukou_type:0,					// 0=非农业 1=农业 户籍类型
		share_id:'',					// 分享人ID
	})

	// 员工入职登记表表单验证
	const Registration_rules = {
	// 1
		address: [
			{
				required: true,
				message: '请输入现地址',
			},
		],
		political_status:[
			{
				required: true,
				message: '请选择政治面貌',
			},
		],
	// 2.
		emergency_contact:[
			{
				required: true,
				message: '请输入紧急联系人',
			},
		],
		emergency_contact_mobile:[
			{
				required: true, 
				message: '请输入紧急联系人电话',
				trigger: ['change','blur'],
			},
			{
				validator: (rule, value, callback) => {
					return uni.$u.test.mobile(value);
				},
				message: '手机号码不正确',
				trigger: ['change','blur'],
			}
		],
		emergency_contact_relation:[
			{
				required: true,
				message: '请输入紧急联系人关系',
			},
		],
		emergency_contact_address:[
			{
				required: true,
				message: '请输入紧急联系人地址',
			},
		],
	
	// 3.
		// contagion_detail:[
		// 	{
		// 		required: true,
		// 		message: '请输入传染病详情',
		// 	},
		// ],
		recent_inspection:[
			{
				required: true,
				message: '请输入近半年体检内容',
			},
		],
		// disability_level:[
		// 	{
		// 		required: true,
		// 		message: '请选择伤残等级',
		// 	},
		// ],

	// 4.
		// resignation_time:[
		// 	{
		// 		required: true,
		// 		message: '请选择上家离职时间',
		// 	},
		// ],
		// reason_to_leave:[
		// 	{
		// 		required: true,
		// 		message: '请输入离职原因',
		// 	},
		// ],
	};

	// 封装判断语句
	const judge_switch = () => {
		switch (pagination.value) {
			case 1:
			entry_registration_title.value = '基本信息'
			break;
			case 2:
			entry_registration_title.value = '紧急联系人'
			break;
			case 3:
			entry_registration_title.value = '健康状况'
			break;
			case 4:
			entry_registration_title.value = '前用人单位信息'
			break;
		}
	}

	// 入职申请合同图片地址
	const entry_application = ref()

	// 上一步点击事件
	const lastStep = () => {
		RegistrationRef.value.validate().then(async (res) => {
			if(res) {
				// 判断 签署员工登记表按钮 是否显示
				if(pagination.value > 1) {
					pagination.value = pagination.value - 1
					judge_switch()
				} else {
					sheep.$helper.toast('已经是第一页了')
				}
			} else {
				if(pagination.value > 1) {
					sheep.$helper.toast('请将数据填写完全再点击！')
				} else {
					sheep.$helper.toast('已经是第一页了')
				}
			}
		}).catch((err) => {
			if(pagination.value > 1) {
					sheep.$helper.toast('请将数据填写完全再点击！')
				} else {
					sheep.$helper.toast('已经是第一页了')
				}
		})

	}
	const entry_id = ref()
	// 下一步点击事件
	const nextStep = () => {
		RegistrationRef.value.validate().then(async (res) => {
			if(res) {
				// 判断 签署员工登记表按钮 是否显示
				if(pagination.value < 4) {
					pagination.value = pagination.value + 1
					judge_switch()
				} else {
					const resust = await sheep.$api.project.postDispatchAdd(RegistrationForm);  // 提交数据
					
					if(resust.code == 1) {
						entry_application.value = resust.data.url
						entry_id.value = resust.data.id
						
						let Combined_data = { ...RegistrationForm, ...introductionView.value }
						let name = ''
						if(RegistrationForm.is_enrollment == 1 || RegistrationForm.is_contact == 1) {
							// 无-有 有-有 有-无
							if(RegistrationForm.is_enrollment == 0 && RegistrationForm.is_contact == 1) {
								name = 'contact'
							}
							if(RegistrationForm.is_enrollment == 1 && RegistrationForm.is_contact == 1) {
								name = 'enrollment'
							}
							if(RegistrationForm.is_enrollment == 1 && RegistrationForm.is_contact == 0) {
								name = 'enrollment'
							}  
							setTimeout(() => {
								sheep.$router.go('/subpackage/user/user/labor_dispatch_pdf',{
									url:entry_application.value,
									id:entry_id.value,
									params:JSON.stringify(Combined_data),
									name: name,
									share_id:share_id.value
								})
							},500)
						} else {
							sheep.$helper.toast(resust.msg)
							setTimeout(() => {
								sheep.$store('user').getInfo();
								sheep.$router.go('/pages/user/user/user')
							},1000)
						}
					} else {
						sheep.$helper.toast(resust.msg)
					}
				}
			} else {
				sheep.$helper.toast(res.msg)
			}
		}).catch((err) => {
			// sheep.$helper.toast('已入职,请勿重复')
		})
	}

	// 表单各种事件集合
		// 婚姻状况
			const marital_status_title = ref('未婚') 
			const marital_status_show = ref(false)
			const marital_status_columns = ref([['未婚','已婚']])
				// 打开
			const marital_status_open = () => {
				marital_status_show.value = true
			}
				// 确定
			const marital_status_confirm = (e) => {
				marital_status_title.value = e.value.join()
				RegistrationForm.marital_status = e.indexs[0]
				marital_status_close()
			}
				// 关闭
			const marital_status_close = () => {
				marital_status_show.value = false
			}
				// 取消
			const marital_status_cancel = () => {
				marital_status_close()
			}

		// 政治面貌
			const political_status_title = ref('群众') 
			const political_status_show = ref(false)
			const political_status_columns = ref([['群众','中共党员','中共预备党员','共青团员']])
				// 打开
			const political_status_open = () => {
				political_status_show.value = true
			}
				// 确定
			const political_status_confirm = (e) => {
				political_status_title.value = e.value.join()
				RegistrationForm.political_status = e.indexs[0]
				political_status_close()
			}
				// 关闭
			const political_status_close = () => {
				political_status_show.value = false
			}
				// 取消
			const political_status_cancel = () => {
				political_status_close()
			}

		// 最高学历
			const education_show = ref(false)
			const education_columns = ref([['中专及以下','大专','本科','研究生及以上']])
				// 打开
			const education_open = () => {
				education_show.value = true
			}
				// 确定
			const education_confirm = (e) => {
				RegistrationForm.education = e.value[0]
				education_close()
			}
				// 关闭
			const education_close = () => {
				education_show.value = false
			}
				// 取消
			const education_cancel = () => {
				education_close()
			}

		// 毕业日期
			const graduation_date_time = ref(946656000000);
			const graduation_date_show = ref(false)
				// 打开
			const graduation_date_open = () => {
				graduation_date_show.value = true
			}
				// 确定
			const graduation_date_confirm = (e) => {
				RegistrationForm.graduation_date = formatDate(e.value/1000)
				graduation_date_close()
			}
				// 关闭
			const graduation_date_close = () => {
				graduation_date_show.value = false
			}
				// 取消
			const graduation_date_cancel = () => {
				graduation_date_close()
			}

		// 入职日期
			const join_date_time = ref();
			const join_date_show = ref(false)
				// 打开
			const join_date_open = () => {
				join_date_show.value = true
			}
				// 确定
			const join_date_confirm = (e) => {
				if (typeof e.value == 'string') {
					RegistrationForm.join_date = e.value
				}
				else {
					RegistrationForm.join_date = formatDate(e.value/1000)
				}
				join_date_close()
			}
				// 关闭
			const join_date_close = () => {
				join_date_show.value = false
			}
				// 取消
			const join_date_cancel = () => {
				join_date_close()
			}

		// 视力选择内容
			const eyesight_columns = ref([
				{
					name: '良好',
					value:'good',
					disabled: false
				},
				{
					name: '辅助',
					value:'bad',
					disabled: false
				},  
			])

		// 听力选择内容
			const hearing_columns = ref([
				{
					name: '良好',
					value:'good',
					disabled: false
				},
				{
					name: '辅助',
					value:'bad',
					disabled: false
				},  
			])

		// 是否曾有工伤
			const is_occupational_injury_columns = ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			])

		// 是否伤残
			const is_disability_columns = ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			])

		// 户籍类型
			const hukou_type_columns = ref([
				{
					name: '非农业',
					value:0,
					disabled: false
				},  
				{
					name: '农业',
					value:1,
					disabled: false
				}
			])

		// 伤残等级
			const disability_level_title = ref('') 
			const disability_level_show = ref(false)
			const disability_level_columns = ref([['1级','2级','3级','4级','5级','6级','7级','8级','9级','10级']])
				// 打开
			const disability_level_open = () => {
				disability_level_show.value = true
			}
				// 确定
			const disability_level_confirm = (e) => {
				disability_level_title.value = e.value.join()
				RegistrationForm.disability_level = e.indexs[0] + 1
				disability_level_close()
			}
				// 关闭
			const disability_level_close = () => {
				disability_level_show.value = false
			}
				// 取消
			const disability_level_cancel = () => {
				disability_level_close()
			}

		// 是否曾高危工作 
			const is_high_risk_columns = ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			])
		
		//  是否有传染病
			const is_contagion_columns = ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			])

		// 离职日期
			const lz_re_time = ref(946656000000);
			const lz_re_time_show = ref(false)
				// 打开
			const lz_re_time_open = () => {
				lz_re_time_show.value = true
			}
				// 确定
			const lz_re_time_confirm = (e) => {
				RegistrationForm.resignation_time = formatDate(e.value/1000)
			lz_re_time_close()
			}
				// 关闭
			const lz_re_time_close = () => {
				lz_re_time_show.value = false
			}
				// 取消
			const lz_re_time_cancel = () => {
				lz_re_time_close()
			}
		// 是否签有保密协议
			const is_confidentiality_agreement_columns = ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			])
		// 是否有纠纷
			const is_legal_dispute_columns= ref([
				{
					name: '是',
					value:1,
					disabled: false
				},
				{
					name: '否',
					value:0,
					disabled: false
				},  
			]) 
</script>

<style lang="scss" scoped>
	@import '../../staff/workbench/compentns/up_sheet.scss';
	// 文本编辑器样式
	:deep(.ql-container) {
		padding: 30rpx 30rpx 0 30rpx;
		background-color: #F9F9F9;
		font-style: normal !important; /* 取消斜体 */
		width: 106% !important;
		margin-left: -30rpx;
		border-radius: 18rpx;
	}
	:deep(#editor) {
		font-style: normal !important; /* 取消斜体 */
	}

	.max_box {
		position: relative;
		background-size: cover;
		background-position: center;
		padding: 0 20rpx;
		.title{
			position: absolute;
			color: #0038F7;
			font-weight: 500;
			font-size: 44rpx;
			left: 22%;
			top: 17.8%;
			z-index: 9;
		}
	}
	.wrap{
		position: relative;
		width: 100%;
		height: 60vh;
		margin: 400rpx auto 0 auto;
		.yellow_bg{
			height: 100rpx;
			width: 100%;
			border-radius: 16rpx;
			background-color: #F8FFFF;
			box-shadow: 0 4rpx 16rpx 0 rgba(0, 0, 0, 0.15);
			position: absolute;
			top: 0;
			left: 0;
			// z-index: 3;
		}
		.wrap_line{
			width: 324rpx;
			height: 74rpx;
			position: absolute;
			left: 27%;
			top: 15rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
			z-index: 3;
			.title{
				color: #FFFFFF;
				font-weight: 400;
				font-size: 34rpx;
				text-align: center;
				width: 60%;
				justify-content: center;
			}
		}
	}
	.labor_dispatching {
		width: 100%;
		height: 65vh;
		background: $uni-bg-color;
		border-radius: 16rpx;
		box-shadow: 0 4rpx 16rpx 0 rgba(0, 0, 0, 0.15);
		position: absolute;
		top: 20rpx;
		left: 0;
		z-index: 2;
		.advertising_position{
			width: 570rpx;
			height: 80rpx;
			margin: 110rpx auto 30rpx auto;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}

	.form_title_box {
		display: flex;
		align-items: center;
	}

	.form_pages {
		padding: 20rpx 0 0 0;
		font-family: PingFangSC;
		color: $uni-text-color;
		font-weight: $uni-font-weight;
		font-size: 34rpx;
		margin-left: 30rpx;
	}

	// 表单盒子
	.form_box {
		padding: 30rpx;
		:deep(.u-form-item){
			margin-bottom: 30rpx !important;
		}
		:deep(.u-form-item__body) {
			height: 80rpx;
			padding: 0 10rpx 0 30rpx;
			background-color: #F9F9F9;
			border-radius: 16rpx;
			.u-form-item__body__left{
				width: 195rpx !important;
				
			}
		}

		:deep(.u-form-item__body__right__content ){
			height: 80rpx !important;
		}
	}
	.nextbutton{
		margin: 0 30rpx;
		border-radius: 50rpx;
		color: #FFFFFF;
		font-weight: $uni-font-weight;
		font-size: 34rpx;
		background: linear-gradient(90deg, rgba(0, 56, 247, 1) 0%, rgba(77, 139, 255, 1) 100%);
	}


	//现住址
	.now_address{
		:deep(.u-form-item__body ){
			height: 180rpx !important;
			.u-form-item__body__left__content__label{
				height: 80rpx !important;
				margin-top: -60rpx;
			}
		}
		:deep(.u-form-item__body__right){
			.u-form-item__body__right__content {
				height: 180rpx !important;
			}
			.input-placeholder{
				color: #606266 !important;
			}
		}
		:deep(.u-textarea){
			background-color: #F9F9F9 !important;
		}
		&:last-child{
			background-color: red !important;
			.u-form-item__body__right__content {
				height: 180rpx !important;
				overflow-y: scroll;
			}
		}
	}
	:deep(.u-form-item__body__right__message ){
		text-align: right;
		margin-top: 10rpx;
	}
	:deep(.u-navbar__content__left){
		.u-icon__icon{
			background: #00000033;
			width: 64rpx;
			height: 64rpx;
			justify-content: center;
			border-radius: 50%;
			color: #fff !important;
		}
	}
	.now_address_add{
		height: 470rpx;
		:deep(.u-form-item__body ){
			flex-direction: column !important;
			background-color:transparent !important;
			.u-form-item__body__left{
				height: 90rpx;
			}
		}
	}
	.button_box {
		display: flex;
		align-items: center;
        font-family: PingFangSC;
        font-weight: $uni-font-weight;
        font-size: 34rpx;
        font-style: normal;
        text-decoration: none;
		margin-bottom: 30rpx;
        
		.left_button {
			border: 2rpx solid #0038F7;
			color: #0038F7;
			width: 50%;
			height: 80rpx;
			border-radius: 50rpx;
			text-align: center;
			line-height: 80rpx;
        	letter-spacing: 1rpx; /* 设置文字间距为2像素 */
			margin: 0 30rpx;
		}
		.right_button {
			background: linear-gradient(90deg, rgba(0, 56, 247, 1) 0%, rgba(77, 139, 255, 1) 100%);
			color: #FFFFFF;
			width: 50%;
			height: 80rpx;
			border-radius: 50rpx;
			text-align: center;
			line-height: 80rpx;
        	letter-spacing: 1rpx; /* 设置文字间距为2像素 */
			margin: 0 30rpx;
		}
	}

	.form_title{
		margin-left: 30rpx;
		padding: 20rpx 0 0 0rpx;
		font-family: PingFangSC;
		color: $uni-text-color;
		font-weight: $uni-font-weight;
		font-size: 34rpx;
		height: 90rpx;
		line-height: 90rpx;
		position: relative;
		&::after {
			content: '';
			position: absolute;
			bottom: 23rpx;
			left: 2%;
			z-index: 9;
			width: 92rpx;
			height: 14rpx;
			border-radius: 10rpx;
			background-color: rgba(0, 56, 247, 0.5);
		}
	}
	:deep(.u-textarea) {
        margin-right: 20rpx !important;
        font-size: 26rpx;
    }
</style>